package org.zhs.springframework;

import java.util.ArrayList;
import java.util.List;

/**
 * 属性值集合
 */
public class PropertyValues {

    private final List<PropertyValue> propertyValueList = new ArrayList<>();

    public void addPropertyValue(PropertyValue value){
        this.propertyValueList.add(value);
    }

    public PropertyValue[] getPropertyValues(){
        return this.propertyValueList.toArray(new PropertyValue[0]);
    }

    /**
     * 获取某一个属性的值
     * @param propertyName
     * @return
     */
    public PropertyValue getPropertyValue(String propertyName){
        for (int i = 0; i < propertyValueList.size(); i++) {
            PropertyValue propertyValue = propertyValueList.get(i);
            if(null != propertyValue && propertyValue.getName().equals(propertyName)){
                return propertyValue;
            }
        }
        return null;
    }

}
